package datastream.api.operator.group.source;

import datastream.api.operator.group.pojo.InputModel;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

public class Source implements SourceFunction<InputModel> {
    @Override
    public void run(SourceContext<InputModel> ctx) throws Exception {
        ctx.collect(new InputModel(1, 1.0,"id1：第1条"));
        Thread.sleep(1000);

        ctx.collect(new InputModel(2, 2.0, "id2：第1条"));
        Thread.sleep(1000);

        ctx.collect(new InputModel(3, 3.0, "id3：第1条"));
        Thread.sleep(1000);

        ctx.collect(new InputModel(2, 20.0, "id2：第2条"));
        Thread.sleep(1000);

        ctx.collect(new InputModel(1, 10.0, "id1：第2条"));
        Thread.sleep(1000);

        ctx.collect(new InputModel(3, 30.0, "id3：第2条"));
    }

    @Override
    public void cancel() {

    }
}
